import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

//  //路由守卫 没有token值 进不去购物车页面
//  beforeEnter:function(to,from,next){
//   if(sessionStorage.getItem("user_token")){
//     next()
//   }else{
//     alert("请先登陆");
//     return false;
//   }
// }

export default new Router({
  // mode:"history",   //路径去掉#
  routes: [
    //路由重定向
    {
      path: "/",
      redirect: "/admin/login"
    },
    //登陆页面
    {
      path: "/admin/login",
      name: "/admin_login",
      component: () => { return import("@/views/admin/login") },
    },
    //主页面
    {
      path: "/admin/index",
      name: "/admin_index",
      component: () => { return import("@/views/admin/index") },
      //子路由
      children: [
        //首页
        {
          path: "/index/home",
          name: "/index_home",
          component: () => { return import("@/views/index/home") },
          //子路由
          children: [
            {
              path: "/home/new1",
              name: "/home_new1",
              component: () => { return import("@/views/home/new1") },
            },
            {
              path: "/home/new2",
              name: "/home_new2",
              component: () => { return import("@/views/home/new2") },
            },
            {
              path: "/home/new3",
              name: "/home_new3",
              component: () => { return import("@/views/home/new3") },
            },
            //路由重定向
            {
              path: "/index/home",
              redirect: "/home/new1"
            },
            //路由重定向
          ]
        },
        //商品
        {
          path: "/index/goods",
          name: "/index_goods",
          component: () => { return import("@/views/index/goods") },
           //子路由
           children: [
            {
              path: "/goods/new1",
              name: "/goods_new1",
              component: () => { return import("@/views/goods/new1") },
            },
            {
              path: "/goods/new2",
              name: "/goods_new2",
              component: () => { return import("@/views/goods/new2") },
            },
            {
              path: "/goods/new3",
              name: "/goods_new3",
              component: () => { return import("@/views/goods/new3") },
            },
            {
              path: "/goods/new4",
              name: "/goods_new4",
              component: () => { return import("@/views/goods/new4") },
            },
            {
              path: "/goods/new5",
              name: "/goods_new5",
              component: () => { return import("@/views/goods/new5") },
            },
            {
              path: "/goods/add",
              name: "/goods_add",
              component: () => { return import("@/views/goods/add") },
            },
            {
              path: "/goods/edit",
              name: "/goods_edit",
              component: () => { return import("@/views/goods/edit") },
            },
            //路由重定向
            {
              path: "/index/goods",
              redirect: "/goods/new1"
            }
          ]
        },
        //订单
        {
          path: "/index/order",
          name: "/index_order",
          component: () => { return import("@/views/index/order") },
            //子路由
            children: [
              {
                path: "/order/new1",
                name: "/order_new1",
                component: () => { return import("@/views/order/new1") },
              },
              {
                path: "/order/new2",
                name: "/order_new2",
                component: () => { return import("@/views/order/new2") },
              },
              {
                path: "/order/new3",
                name: "/order_new3",
                component: () => { return import("@/views/order/new3") },
              },
              //路由重定向
              {
                path: "/index/order",
                redirect: "/order/new1"
              }
            ]
        },
        //会员
        {
          path: "/index/member",
          name: "/index_member",
          component: () => { return import("@/views/index/member") },
              //子路由
              children: [
                {
                  path: "/member/new1",
                  name: "/member_new1",
                  component: () => { return import("@/views/member/new1") },
                },
                {
                  path: "/member/new2",
                  name: "/member_new2",
                  component: () => { return import("@/views/member/new2") },
                },
                //路由重定向
                {
                  path: "/index/member",
                  redirect: "/member/new1"
                }
              ]
        },
        //设置
        {
          path: "/index/setup",
          name: "/index_setup",
          component: () => { return import("@/views/index/setup") },
            //子路由
            children: [
              {
                path: "/setup/new1",
                name: "/setup_new1",
                component: () => { return import("@/views/setup/new1") },
              },
              {
                path: "/setup/new2",
                name: "/setup_new2",
                component: () => { return import("@/views/setup/new2") },
              },
              {
                path: "/setup/new3",
                name: "/setup_new3",
                component: () => { return import("@/views/setup/new3") },
              },
              {
                path: "/setup/new4",
                name: "/setup_new4",
                component: () => { return import("@/views/setup/new4") },
              },
              //路由重定向
              {
                path: "/index/setup",
                redirect: "/setup/new1"
              }
            ]
        },
        //路由重定向
        {
          path: "/admin/index",
          redirect: "/index/home"
        }
      ]
    },


  ]
})
